<!DOCTYPE html>
<html>

<head>

    {include file="Public/header"}
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/plugins/webuploader/webuploader.css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/demo/webuploader-demo.css">

    <style>
        .radio-inline input[type=radio] {
            margin-top: 4px
        }
    </style>
</head>

<body style="color:#333;padding:3px;">
<!-- 标题 -->
<div class="page-heade">
    <h2 class="title_color text-center">非常规促销活动执行情况反馈</h2>
</div>
<!-- 标题 -->
<div>
    <div action="" class="form-inline">
        <table class="table table-bordered bud_hei" style="margin-top:0">
            <tr>
                <td style="min-width: 120px;width: 120px"><label for="" class="form-label">主题：</label></td>
                <td colspan="3">{$data.title}</td>
                <td style="min-width: 120px;width: 120px"><label for="" class="form-label">活动类型：</label></td>
                <td>非常规促销</td>
            </tr>
            <tr>
                <td style="min-width: 120px;width: 120px"><label for="" class="form-label">经销商：</label></td>
                <td colspan="3">{$data.jxs_title}</td>
                <td style="min-width: 120px;width: 120px"><label for="" class="form-label">日期：</label></td>
                <td>{:date('Y-m-d H:i',$data.ctime)}</td>
            </tr>
            <tr>
                <td style="min-width: 120px;width: 120px"><label for="" class="form-label">所属部门：</label></td>
                <td colspan="3">待做</td>
                <td style="min-width: 120px;width: 120px"><label for="" class="form-label">原申请编号：</label></td>
                <td><a href="{:url('view',['id'=>request()->param('id')])}">{$data.sn}</a></td>
            </tr>
            <tr>
                <td style="min-width: 120px;width: 120px"><label for="" class="form-label">反馈人：</label></td>
                <td colspan="5"><a href="javascript:;">{:db('employee')->where('id',session('employee_id'))->value('em_name')}</a></td>
            </tr>
            <tr>
                <td style="min-width: 120px;width: 120px"><label for="" class="form-label font-bold">温馨提示：</label></td>
                <td class="font-bold" colspan="5">如果您需要整单反馈(直接反馈活动总销量及各费用科目的实际投入情况)，请点击<a href="javascript:;"
                                                                                          id="toallDanFk">进入整单反馈页面</a>。
                </td>
            </tr>
        </table>
        <table class="table table-bordered bud_hei text-center" id="table1">
            <tr class="info">
                <th class="text-center" rowspan="2">序号</th>
                <th class="text-center" rowspan="2">{$arealat1}</th>
                <th class="text-center" rowspan="2">{$arealat2}</th>
                <th class="text-center" rowspan="2">{$productlat}</th>
                <th class="text-center" colspan="2">总销量(元)</th>
                <th class="text-center" colspan="4">现结返利\团购返利(元)<br><span>东菀市宝多丰贸易有限公司</span></th>
            </tr>
            <tr class="info">
                <th class="text-center">预计</th>
                <th class="text-center">实际</th>
                <th class="text-center">预计投入</th>
                <th class="text-center">实际未税</th>
                <th class="text-center">是否增值税</th>
                <th class="text-center">税率</th>
            </tr>
7




            {volist name="data.list" id="row" key="k"}
            <tr class="data" data-net_id="{$row.net_id}" data-pid="{$row.p_id}">
                <td>{$k}</td>
                <td>{$row.arealat_sn}</td>
                <td>{$row.arealat_title}</td>
                <td>{$row.productlat_title}</td>
                <td class="ObjectNum">{:round($row.yujixiaoliang,2)}</td>
                <td class="text-right"><input type="text" name="realsales" class="form-control"
                                              style="min-width: 100px;width: 100px" value="{:round($row.yujixiaoliang,2)}"></td>
                <td class="ObjectNum">{:round($row.yujitouru,2)}</td>
                <td class="text-right"><input type="text" name="realamount" class="form-control"
                                              style="min-width: 100px;width: 100px" value="{:round($row.yujitouru,2)}"></td>
                <td>
                    <label class="radio-inline">
                        <input type="radio" name="inlineRadioOptionse{$k}" value="1">是
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="inlineRadioOptionse{$k}" value="0" checked>否
                    </label>
                </td>
                <td class="text-right"><input type="text" name="shuilv" class="form-control"
                                              style="min-width: 60px;width: 60px" value="0.00">%
                </td>
            </tr>
            {/volist}
            <tr class="trTotal1">
                <td colspan="4">合计</td>
                <td class="ObjectNum">{$data.totalExpectedSales}</td>
                <td class="ObjectNum real_zong" >{$data.totalExpectedSales}</td>
                <td class="ObjectNum">{$data.totalAmount}</td>
                <td class="ObjectNum real_zong2">{$data.totalAmount}</td>
                <td></td>
                <td></td>
            </tr>
            <tr class="text-left">
                <td class="font-bold" colspan="10">总销量为：<span class="ObjectNum real_zong" >{$data.totalExpectedSales}</span>；总投入为：<span
                        class="ObjectNum real_zong2">{$data.totalAmount}</span>元；实际费用率：<span class="ObjectNum" id="feiyonglv">{:round($data.totalAmount/$data.totalExpectedSales*100,2)}</span>%
                </td>
            </tr>
        </table>
        <table class="table-bordered table">
            <tr>
                <td rowspan="3" class="text-center" style="min-width: 120px;width: 120px">活动策划内容:</td>
                <td>{$data.brief}</td>
            </tr>
        </table>
        <table class="table-bordered table">
            <tr>
                <td rowspan="3" class="text-center" style="min-width: 120px;width: 120px">备注:</td>
                <td><textarea name="brief" id="brief" class="form-control" style="width: 60%;overflow: auto;"></textarea><span
                        style="vertical-align: bottom;">(500)</span></td>
            </tr>
        </table>
        <div class="form-group white-bg" style="margin:20px 10px 20px 20px;">
            {if isset($attach)}
            <ul class="list-group">
                {volist name="attach" id="row"}
                <li class="list-group-item">
                    <a class="badge badge-primary removeIt" data-id="{$row.id}">移除</a>
                    <a href="{$row.path}" target="_blank">{$row.file_name}</a></li>
                {/volist}
            </ul>
            {/if}
            <div id="uploader" class="wu-example">
                <!--用来存放文件信息-->
                <div id="thelist" class="uploader-list"></div>
                <div class="btns">
                    <div id="picker">选择文件</div>
                    <button id="ctlBtn" class="btn btn-default">开始上传</button>
                </div>
                <input type="hidden" name="attach" id="attach">
                <input type="hidden" name="remove" id="remove">
            </div>
            <span>注：最多上传15个文件，每个文件小于50M,支持格式：</span><br>jpg,bnp,gif,png,jpeg,tif,raw,doc,docx,xls,xlsx,ppt,pptx,txt,pdf,rar,zip,mp4,avi,rmvb,rm,mid,3gp,AVI,3GP,,mpg,mp3,wma,wav
        </div>

        <div class="row sub_btn" style="width:100%;text-align:center;padding: 20px 0">
            <input type="submit" class="btn btn-success save" value="保存为草稿" id="save1">
            <input type="submit" class="btn btn-info save" value="保存并提交工作流" id="save2">
            <input type="submit" class="btn btn-warning" value="返回" onclick="location.href='{:url('index')}'">
        </div>
    </div>
</div>
{include file="Public/footer"}
<!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
<script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="__STATIC__/layout/js/plugins/layer/laydate/laydate.js"></script>
<script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="__STATIC__/layout/js/common.js"></script>
<script>
    $(document).ready(function () {
        var $ObjectNum = $(".ObjectNum");
        toNum($ObjectNum);

        /*进入整单反馈页面*/
        $("#toallDanFk").click(function () {
            var _$this = this
            swal({
                    title: "",
                    text: "页面跳转后，当前页面已编辑的数据将不被保存，您确定跳转吗？",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "确定",
                    cancelButtonText: "取消",
                    closeOnConfirm: false,
                    closeOnCancel: false
                },
                function (isConfirm) {
                    if (isConfirm) {
                        // console.log(_$this);
                        swal("", "", "success");
                        location.href = "{:url('feedback',['id'=>request()->param('id'),'feedbacktype'=>0])}"
                    } else {
                        swal("取消！", "", "error");
                    }
                });
        })

        //输入实际总销量
        $('[name=realsales]').on('input',function () {
            var total = 0
            $('[name=realsales]').each(function () {
                total+=parseFloat($(this).val())
            })

            $('.real_zong').html(total.toFixed(2))

            var total2 = 0
            $('[name=realamount]').each(function () {
                total2+=parseFloat($(this).val())
            })
            $('#feiyonglv').html((total2*100/total).toFixed(2))
        })

        //输入实际未税
        $('[name=realamount]').on('input',function () {
            var total = 0
            $('[name=realamount]').each(function () {
                total+=parseFloat($(this).val())
            })
            $('.real_zong2').html(total.toFixed(2))

            var total2 = 0
            $('[name=realsales]').each(function () {
                total2+=parseFloat($(this).val())
            })
            $('#feiyonglv').html((total*100/total2).toFixed(2))
        })

        //保存为草稿
        $('.save').on('click',function () {
            var data = {}

            var bool = true
            var arr = []
            $('#table1 tr.data').each(function () {
                var realsales = $(this).find('[name=realsales]').val()
                if(realsales==''){
                    swal('请输入实际总销量','','error')
                    bool = false
                    return false
                }
                var realamount = $(this).find('[name=realamount]').val()
                if(realamount==''){
                    swal('请输入实际未税','','error')
                    bool = false
                    return false
                }
                var shuilv = $(this).find('[name=shuilv]').val()
                if(shuilv==''){
                    swal('请输入税率','','error')
                    bool = false
                    return false
                }
                var xid = $(this).data('net_id') //netid
                var pid = $(this).data('pid') //netid
                var isVAT = $(this).find('[type=radio]:checked').val()

                arr.push({
                    realsales:realsales,
                    realamount:realamount,
                    real_shuilv:shuilv,
                    net_id:xid,
                    pid:pid,
                    isVAT:isVAT
                })

            })

            if(bool==false){
                return false
            }
            data.arr = arr
            var brief = $('#brief').val()
            data.brief = brief
            var attach = $('#attach').val()
            var remove = $('#remove').val()
            data.attach = attach
            data.remove = remove
            data.productlat = '{$data.productlat}'
            var savetype = $(this).prop('id')
            data.savetype = savetype
            $.post('',data,function (data) {
                if(data.success){
                    swal({
                        title:data.msg,
                        type:'success'
                    },function () {
                        location.href = '{:url("index")}'
                    })
                }else
                    swal(data.msg, "", "error");

            },'json')
            return false
        })
    })

    function back() {
        history.go(-1)
    }
</script>
</body>
<!-- Web Uploader -->
<script type="text/javascript">
    // 添加全局站点信息
    var BASE_URL = '__STATIC__/layout/js/plugins/webuploader';
</script>
<script src="__STATIC__/layout/js/plugins/webuploader/webuploader.min.js"></script>
<script>
    // 文件上传
    jQuery(function() {
        var $ = jQuery,
            $list = $('#thelist'),
            $btn = $('#ctlBtn'),
            state = 'pending',
            uploader;

        var ids = [];
        uploader = WebUploader.create({

            // 不压缩image
            resize: false,

            // swf文件路径
            swf: BASE_URL + '/js/Uploader.swf',

            // 文件接收服务端。
            server: '{:url("upload/fileupload")}',

            // 选择文件的按钮。可选。
            // 内部根据当前运行是创建，可能是input元素，也可能是flash.
            pick: '#picker'
        });

        // 当有文件添加进来的时候
        uploader.on( 'fileQueued', function( file ) {
            $list.append( '<div id="' + file.id + '" class="item">' +
                '<h4 class="info">' + file.name + '</h4>' +
                '<p class="state">等待上传...</p>' +
                '</div>' );
        });

        // 文件上传过程中创建进度条实时显示。
        uploader.on( 'uploadProgress', function( file, percentage ) {
            var $li = $( '#'+file.id ),
                $percent = $li.find('.progress .progress-bar');

            // 避免重复创建
            if ( !$percent.length ) {
                $percent = $('<div class="progress progress-striped active">' +
                    '<div class="progress-bar" role="progressbar" style="width: 0%">' +
                    '</div>' +
                    '</div>').appendTo( $li ).find('.progress-bar');
            }

            $li.find('p.state').text('上传中');

            $percent.css( 'width', percentage * 100 + '%' );
        });

        uploader.on( 'uploadSuccess', function( file,response) {
            if(response.success)
                ids.push(response.id)
            $( '#'+file.id ).find('p.state').text(response.msg);
        });

        uploader.on( 'uploadError', function( file ) {
            $( '#'+file.id ).find('p.state').text('上传出错');
        });

        uploader.on( 'uploadComplete', function( file ) {
            $('#attach').val(ids.join(','))
            $( '#'+file.id ).find('.progress').fadeOut();
        });

        uploader.on( 'all', function( type ) {
            if ( type === 'startUpload' ) {
                state = 'uploading';
            } else if ( type === 'stopUpload' ) {
                state = 'paused';
            } else if ( type === 'uploadFinished' ) {
                state = 'done';
            }

            if ( state === 'uploading' ) {
                $btn.text('暂停上传');
            } else {
                $btn.text('开始上传');
            }
        });

        $btn.on( 'click', function() {
            if ( state === 'uploading' ) {
                uploader.stop();
            } else {
                uploader.upload();
            }
            return false
        });

    });
</script>
</html>